from Detector.FaultStartTimeDetector import FaultStartTimeDetector
from Detector.FaultTypeDetector import FaultTypeDetector
from parser.cfg_parser import CfgParser
from parser.dat_parser import Data_file

if __name__ == '__main__':
    mno = [41, 42, 43, 44]

    file_name = '2025-02-14_15-16-56_ACT_14577#录波装置'

    cfg_obj = CfgParser(f'data/{file_name}.cfg')
    if not cfg_obj.parse():
        raise ValueError(f"CFG文件解析失败: {file_name}.cfg")

    data_file = Data_file(cfg_obj)
    if not data_file.check_file():
        raise ValueError("数据文件不存在或校验失败")

    data_file.parse_data(use_optimized=True)
    data_file.get_channels_data(mno)
    df = data_file.export_data()

    fault_time = FaultStartTimeDetector().detect(df, cfg_obj)

    res = FaultTypeDetector().detect(df, fault_time, cfg_obj)

    print(res)